﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using mshtml;
using SHDocVw;
using System.Runtime.InteropServices;

namespace XDLogonMonitor
{
    class Program
    {
        static void Main(string[] args)
        {
            
            //DateTime.Now.ti
            /* _MONITOR_SERVER_APPLICATION_
             * START
             * Read Configuration
             * Create Open Port 80, _WAIT_ for READY
             * Modify Registry for MOTD 
             * OpenIE                           VARIABLE: IEOpenTime
             * Confirm IE is open and running
             * Process Login                    VARIABLE: WILoginTime
             * Process Desktop Launch           VARIABLE: DSKLaunchTime   
             * Confirm Receiver Launch          VARIABLE: StartTime
             * _WAIT_ for EVENT                 VARIABLE: EventTime
             * _WAIT_ for EXPLORER              VARIABLE: ExplorerTime
             * _WAIT_ for STARTUP               VARIABLE: EndTime
             * Upload to Database
             * END
             */

            /*
             * 	CREATE TABLE Events ( EventId INT IDENTITY(1,1) PRIMARY KEY , 
             * 	EventNum BIGINT,
             * 	EventType SMALLINT,
             * 	EventTime DATETIME,
             * 	ComputerName VARCHAR(15))
             */ 	

           

            /* _DESKTOP_SERVICE_
             * Connect Port 80 to Monitor Server
             * Send "READY: <COMPUTERNAME>"
             * Read Event Log, when 528, Send "EVENT: <TIME>"
             * Check if explorer.exe is running, Send "EXPLORER: <TIME>"
             * Check if cmd.exe is running, Send "STARTUP: <TIME>"
             * 
             */

            /* _BATCH_FILE_
             * echo "Monitoring PC, leave alone, will automatically reboot."
             * @ping 127.0.0.1 -n 120 -w 1000 > nul
             * shutdown -l
             */

            //DesktopProcessThread dpt = new DesktopProcessThread("USPPXDXP02");

            //VMware.VmPowerOps vmPowerOps = new VMware.VmPowerOps("XP-TEMPLATE3", "on");

            //UserInformation ui = new UserInformation();
            //ui.UserLoginTime("jcallen", "USPPXDXP4");
            //int count = 0;
            //while (count < 10)
            //{
            IEDDCControl control = new IEDDCControl();

            control.username = "jcallen";
           

            control.OpenIE("http://10.53.2.60");
            control.ProcessLogin();
            control.ProcessDesktopLaunch(false);
            control.ProcessLogout();
            //    count++;
            //}

            Console.In.ReadLine();
        }
    }
}
